package gongjiao.yunxi.com.utilsprivacypolicy;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;

import com.utils.lib.utilsview.UDialog;


public class MainActivity extends AppCompatActivity {
    UDialog dialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (null == dialog) {
            dialog = new UDialog(MainActivity.this, "权限提示!",
                    "打开", "退出",
                    "此应用需要打开定位、存储权限，否则部分功能将无法正常使用，是否打开？", new UDialog.ClickListener() {
                @Override
                public void doConfirm() {
                    Intent intent = new Intent();
//                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                    intent.setData(Uri.fromParts("package", getPackageName(), null));
                    startActivity(intent);
                    dialog.dismiss();
                }

                @Override
                public void doCancel() {
                    finish();
                }

                @Override
                public void doDismiss() {
                }
            });
        }
        dialog.show();
        findViewById(R.id.tv_line111).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null == dialog) {
                    dialog = new UDialog(MainActivity.this, "权限提示!",
                            "打开", "退出",
                            "此应用需要打开定位、存储权限，否则部分功能将无法正常使用，是否打开？", new UDialog.ClickListener() {
                        @Override
                        public void doConfirm() {
                            Intent intent = new Intent();
//                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                            intent.setData(Uri.fromParts("package", getPackageName(), null));
                            startActivity(intent);
                            dialog.dismiss();
                        }

                        @Override
                        public void doCancel() {
                            finish();
                        }

                        @Override
                        public void doDismiss() {
                        }
                    });
                }
                dialog.show();
            }
        });
//
//        StatusBarUtil.setColor(this, getResources().getColor(R.color.u_color33),0);
//        setContentView(R.layout.activity_main);
//
//        UConstant.initConstant("adsense","getAdInfo","1","anzi",
//                "100019","a4bf209165bf170e5a8a344dcfd850a0","","",
//                "http://api.sjsj.cn/index.php");
//        UNewNetwork instance = UNewNetwork.getInstance();
//        instance.initAdHttp("1", new UNewNetwork.OnHttpListener() {
//            @Override
//            public void succeed(UADModel o) {
//                Log.d("--111--",o.getData().getIsStatus()+"");
//            }
//
//            @Override
//            public void error() {
//
//            }
//        });


    }

    @Override
    protected void onStop() {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        super.onStop();
    }
}
